{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=1165
  Verdict: Accepted
}
uses 
	SysUtils, Math;
 
var  	
	i,n,q,x,y:longint;
	a:array[0..100010] of longint;
 
function siftdown(i:longint):longint;
 
var 
  j,t:longint;
 
begin
while 2*i<=n do begin
  j:=i;
	if a[2*i]>a[j] then j:=2*i;
	if (2*i+1<=n) and (a[2*i+1]>a[j]) then j:=2*i+1;
  if i<j then begin
    t:=a[i];
    a[i]:=a[j];
    a[j]:=t;
    i:=j;
	end else break;
end;
result:=i;
end;
 
begin
reset(input,'input.txt');
rewrite(output,'output.txt');
read(n);
for i:=1 to n do
	read(a[i]);
read(q);
for i:=1 to q do begin
	read(x,y);
	dec(a[x],y);
	writeln(siftdown(x));
end;
for i:=1 to n do
	write(a[i],' ');
end.